<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <!--因为需要获取文本框的值,所以让文本框的值和num的值双向绑定3-->
    <input type="text" placeholder="请输入1-100之间的整数" v-model="num">
    <input type="button" value="猜一猜" @click="f()">
    <h1>{{info}}</h1>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let su = parseInt(Math.random()*100)+1;
    let v = new Vue({
        el:"div",
        data:{
            info:"",
            num:""
        },
        methods:{
            f:function () {
                if (v.num>su){
                    v.info="猜大了";
                }else if (v.num<su){
                    v.info="猜小了";
                }else {
                    v.info="猜对了";
                }
            }
        }
    })
</script>
</body>
</html>